﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace PServiceBus.Services.Gateway.Configurations {
    internal class ESBRouterElement : ConfigurationElement {
        public ESBRouterElement() { }
        public ESBRouterElement(string endpoint) { Endpoint = endpoint; }
        [ConfigurationProperty("endpoint", IsRequired = true, IsKey= true)]
        public string Endpoint {
            get { return base["endpoint"] as string; }
            set { base["endpoint"] = value; }
        }
    }
    [ConfigurationCollection(typeof(ESBRouterElement), CollectionType = ConfigurationElementCollectionType.BasicMap)]
    internal sealed class ESBRouterCollection : ConfigurationElementCollection {
        protected override ConfigurationElement CreateNewElement() {
            return new ESBRouterElement();
        }

        protected override object GetElementKey(ConfigurationElement element) {
            return (element as ESBRouterElement).Endpoint;
        }
    }
    public sealed class ESBRouterConfigSection : ConfigurationSection {
        [ConfigurationProperty("routers", IsDefaultCollection = true, IsRequired = true)]
        internal ESBRouterCollection Routers {
            get { return this["routers"] as ESBRouterCollection; }
        }
    }
}
